// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class Hp extends cc.Component {

    static i: Hp = null;

    private value : number = 0;
    private label : cc.Label = null;

    // LIFE-CYCLE CALLBACKS:

    onLoad () {

        Hp.i = this;

        this.label = this.node.getComponent(cc.Label);
        this.clearHp();
    }

    getHp() {

        return this.value;
    }

    clearHp() {

        this.value = 0;
        this.label.string = this.value + '';

        //this.label.node.scale = 1;
    }

    updateHp(n : number) {

        this.value = n;
        this.label.string = this.value + '';

        /*
        cc.tween(this.node)
          .by(0.5, {scale: 0.3})
          .by(0.2, {scale: -0.3})
          .start();*/
    }

    // update (dt) {}
}
